import HomeView from "./views/Home";
import UserView from "./views/User";
import { BrowserRouter, Link, Routes, Route } from "react-router-dom";
import {KeepAlive, KeepAliveTransfer} from "./keepAlive";

const AliveHomeView = KeepAliveTransfer(HomeView, "home");
const AliveUserView = KeepAliveTransfer(UserView, "user");

function App() {
  return (
    <BrowserRouter>
      <KeepAlive>
        <div>
          <ul>
            <li>
              <Link to={"/"}>Home</Link>
            </li>
            <li>
              <Link to={"/user"}>User</Link>
            </li>
          </ul>
          <div>
            <Routes>
              <Route path="/" element={<AliveHomeView />} />
              <Route path="/user" element={<AliveUserView />} />
            </Routes>
          </div>
        </div>
      </KeepAlive>
    </BrowserRouter>
  );
}

export default App;
